home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
gymMatChar.lua
< prev
next >
Wrap
Text File
|
2004-01-29
|
2KB
|
100 lines
-- mat character state machine
beginStateMachine()
onEnter(function(msg)
local mat = getStateObjectFromID(msg.sender);
storeStateObject("mat", mat);
if (mat) then
-- mat does exist
if (getParent().isOneActionPointLocked(mat)) then
-- action point is locked
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
else
getParent().lockActionPoints(mat);
end
else
-- mat does not exist anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
freeHands(getParent());
end )
onExit(function(msg)
-- local mat = retrieveStateObject("mat");
-- getParent().unlockActionPoints(mat);
-- getParent().stopAllActivities(mat);
-- removeStateObject("mat");
unlockAll("mat");
end )
state("pushupStart")
onEnter(function(msg)
startAnimation("pushupDown");
end )
onMsg("end", function(msg)
if testCancel() then
setState("pushupEnd");
else
setState("pushupLoop");
end
end )
state("pushupLoop")
onEnter(function(msg)
local mat = retrieveStateObject("mat");
local makePushups = getParent().startActivity("makePushups", mat);
local length, scale = getActivityLength(makePushups);
scale = scale * 0.5; --make push ups slower
storeData("scale", scale);
startAnimation("pushupLoop", false, scale);
sendDelayedMsgThis("stopPushups", length);
print("npa length:" .. length);
end )
onMsg("stopPushups", function(msg)
local mat = retrieveStateObject("mat");
getParent().stopActivity("makePushups", mat);
setState("pushupEnd");
end )
onMsg("breathe", function(msg)
getParent().playSound(genderizeReal(getParent(), "atem" .. random(1,2)));
end )
onMsg("end", function(msg)
if testCancel() or (not getParent().getCurrentActivityGain()) or (getParent().getCondition(NEED_TIREDNESS) < 0.1) then
sendMsgThis("stopPushups");
else
startAnimation("pushupLoop", false, retrieveData("scale", 1.0));
if (random() < 0.5) then sendMsgThis("breathe"); end;
end
end )
state("pushupEnd")
onEnter(function(msg)
startAnimation("pushupDown", false, -1);
end )
onMsg("end", function(msg)
exitAndGoAway();
end )
endStateMachine()